import { createContext, type Dispatch, type MutableRefObject, type SetStateAction } from 'react';
import type VoiceBotService from '@/utils/voice_bot_service';

type AudioChatServiceContextType = {
  wsUrl: string;
  setWsUrl: Dispatch<SetStateAction<string>>;
  //
  logContent: string[];
  setLogContent: Dispatch<SetStateAction<string[]>>;
  //
  serviceRef: MutableRefObject<VoiceBotService | null>;
  recorderRef: MutableRefObject<any>;
  waveRef: MutableRefObject<any>;
  wsReadyRef: MutableRefObject<boolean>;
  //
  sendPcmBufferRef: MutableRefObject<Int16Array>;
  sendChunkRef: MutableRefObject<any>;
  sendLastFrameRef: MutableRefObject<Int16Array | null>;
  //
  currentSpeaker: string;
  setCurrentSpeaker: Dispatch<string>;
  configNeedUpdateRef: MutableRefObject<boolean>;
  //
  currentUserSentence: string;
  setCurrentUserSentence: Dispatch<SetStateAction<string>>;
  currentBotSentence: string;
  setCurrentBotSentence: Dispatch<SetStateAction<string>>;
};

export const AudioChatServiceContext = createContext<AudioChatServiceContextType>(
  {} as unknown as never
);
